package com.awei.study.design.action.strategy;

/**
 * @Author liweilong
 * @Date 2024/8/13 19:26
 */
public class Strategy {
    public static abstract class StrategyActivity {
        public abstract void show();
    }

    public static class ActivityA extends StrategyActivity {

        @Override
        public void show() {
            System.out.println("买一送一");
        }
    }

    public static class ActivityB extends StrategyActivity {

        @Override
        public void show() {
            System.out.println("买三百减二十");
        }
    }

    public static class ActivityC extends StrategyActivity {

        @Override
        public void show() {
            System.out.println("全场七折");
        }
    }

    public static class SellMan {
        private StrategyActivity ac;

        public SellMan(StrategyActivity ac) {
            this.ac = ac;
        }

        public void introduce() {
            ac.show();
        }
    }

    public static void main(String[] args) {
        StrategyActivity acA = new ActivityA();
        StrategyActivity acB = new ActivityB();
        StrategyActivity acC = new ActivityC();
        SellMan sellMan;
        sellMan = new SellMan(acA);
        sellMan.introduce();
        sellMan = new SellMan(acB);
        sellMan.introduce();
        sellMan = new SellMan(acC);
        sellMan.introduce();
    }
}
